<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Get User Location</title>
</head>
<body>
    <h1>Geolocation Example</h1>
    <button id="getLocationBtn">Get My Location</button>
    <div id="locationInfo"></div>

    <script>
        document.getElementById("getLocationBtn").addEventListener("click", () => {
            if ("geolocation" in navigator) {
                navigator.geolocation.getCurrentPosition(
                    (position) => {
                        const { latitude, longitude, accuracy } = position.coords;
                        document.getElementById("locationInfo").innerHTML = `
                            <p>Longitude,Latitude: ${longitude},${latitude}</p>
                            <p>Accuracy: ${accuracy} meters</p>
                        `;
                    },
                    (error) => {
                        document.getElementById("locationInfo").innerHTML = `
                            <p>Error: ${error.message}</p>
                        `;
                    },
                    {
                        enableHighAccuracy: true,
                        timeout: 5000,
                        maximumAge: 0
                    }
                );
            } else {
                document.getElementById("locationInfo").innerHTML = `
                    <p>Geolocation is not supported by this browser.</p>
                `;
            }
        });
    </script>
</body>
</html>